﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.woodsoft.core;
using com.woodsoft.core.Files;
using EQ1.Objects;

namespace EQ1.Controls {
  public class HotButton : Button , IUIElement<HotButton> {
    public HotButton ( UIDocument doc , string name )
      : base( doc , name ) {
    }
    public HotButton ( UIDocument doc )
      : this( doc , "HotButton" ) {
    }

    #region IUIElement<HotButton> Members

    public void Validate ( HotButton val , string name ) {
      UIClass par = ( UIClass ) this.ParentNode;

      if( val.LocalName != name ) {
        HotButton el = new HotButton( ( UIDocument ) val.OwnerDocument , name );
        el.Copy( val );
        val = el;
      }

      if( par.GetElement( name ) != null )
        par.RemoveElement( name );

      par.AppendChild( val );
    }

    public void Copy ( HotButton val ) {
      base.Copy( val );

      if( !string.IsNullOrEmpty( val.InvSlot ) )
        this.InvSlot = val.InvSlot;
      if( !string.IsNullOrEmpty( val.SpellGem ) )
        this.SpellGem = val.SpellGem;
    }

    #endregion

    public string InvSlot {
      get {
        return this.GetElement( "InvSlot" ).InnerText;
      }
      set {
        this.Validate( "InvSlot" , value );
      }
    }
    public string SpellGem {
      get {
        return this.GetElement( "SpellGem" ).InnerText;
      }
      set {
        this.Validate( "SpellGem" , value );
      }
    }
  }
}
